//sigaction用法
#include <iostream>
using namespace std;
#include <cstring>
#include <signal.h>
#include <unistd.h>
void printPending()
{
    sigset_t pending;
    sigpending(&pending);
    for(int i=1;i<32;i++)
    {
        if(sigismember(&pending,i))
        {
            cout<<"1";
        }
        else{
            cout<<"0";
        }
    }
    cout<<endl;

}
void handler(int signo)
{
    cout<< "i ret signo is:"<<signo<<endl;
    while(1)
    {
        printPending();
        sleep(1);
    }
}
int main()
{
    struct sigaction act,oact;
    memset(&act,0,sizeof(act));
    memset(&oact,0,sizeof(oact));
    sigemptyset(&act.sa_mask);
   sigaddset(&act.sa_mask,1);
    sigaddset(&act.sa_mask,3);
    sigaddset(&act.sa_mask,4);
    act.sa_handler=handler;
    sigaction(2,&act,&oact);
    while(1)
    {
        cout<<"i am process ,pid is:"<<getpid()<<endl;
        sleep(1);
    }
    return 0;
}